<template>
	<view class="page">
		<u-navbar :auto-back="true" :title="title">
			<view class="u-nav-slot" slot="right">
				<view class="nav-right" @click="openPopUp">
					<!-- <u-icon name="search" size="24" color="#376CB4"></u-icon> -->
					<u-icon name="list" size="24" style="margin-left: 20rpx;" color="#000"></u-icon>
				</view>

			</view>
		</u-navbar>
		<!-- 期刊动态 -->
		<view class="qk-dynamic">
			
			<view class="search-empty" v-if="rst.length <= 0">
				<image src="../../static/kong.png" class="empty-img"></image>
			</view>
			
			<view class="qk-dynamic-box">
				<view class="qk-dynamic-box-item" @click="gotoDetail(item)" v-for="(item,index) in rst" :key="index">
					<image :src="item.photo" v-if="item.photo" class="qk-dynamic-box-item-img"></image>

					<view class="qk-dynamic-box-item-content" v-if="item.photo">
						<view class="qk-dynamic-box-item-content-t font-28">
							{{item.title}}
						</view>
						<view class="qk-dynamic-box-item-content-b">
							<view class="font-24">{{item.addtime}}</view>
							<view class="font-24 qk-dynamic-box-item-content-bbb">
								<u-icon name="eye" style="margin-right: 10rpx;" color="#999999" size="18"></u-icon>
								<text>{{item.hits}}</text>
							</view>
						</view>
					</view>

					<view class="qk-dynamic-box-item-content" style="width: 670rpx;" v-if="!item.photo">
						<view class="qk-dynamic-box-item-content-t font-28">
							{{item.title}}
						</view>
						<view class="qk-dynamic-box-item-content-b">
							<view class="font-24">{{item.addtime}}</view>
							<view class="font-24 qk-dynamic-box-item-content-bbb">
								<u-icon name="eye" style="margin-right: 10rpx;" color="#999999" size="18"></u-icon>
								<text>{{item.hits}}</text>
							</view>
						</view>
					</view>

				</view>
			</view>
		</view>
		<Footer></Footer>
		<CommonTk  ref="commonTk"></CommonTk>
	</view>
</template>

<script>
	import {
		api,
		BaseImgUrl,
		http
	} from '@/config/common.js'
	import Footer from '@/components/Footer.vue'
	import CommonTk from '@/components/CommonTk.vue'
	export default {
		data() {
			return {
				page: 1,
				total_page: 1,
				rst: [],
				isXj:false,
				title:'期刊动态'
			}
		},
		components: {CommonTk,Footer},
		filters: {},
		mounted() {},
		onLoad(e) {
			if (e.isxj) {
				this.isXj = true
				this.title = '精选期刊'
			}
			this.getQkDt()
		},
		onShow() {},
		beforeDestroy() {},
		onReachBottom() {
			if (this.page < this.total_page) {
				this.page = this.page + 1
				this.getQkDt()
			} else {
				console.log('no more')
			}
		},
		methods: {
			openPopUp() {
				this.$refs.commonTk.openShow()
			},
			//期刊动态
			getQkDt() {
				api.post('api/index/columns', {
					id: 27,
					page: this.page,
					isxj:this.isXj
				}).then(res => {
					let rst = res.data
					if (rst.code == 1) {
						let result = rst.data
						this.total_page = result.last_page
						let temp_rst = result.data;
						temp_rst.forEach(function(item, index) {
							temp_rst[index]['photo'] = BaseImgUrl + 'upfile/' + item.photo
						});
						this.rst = this.rst.concat(temp_rst)
					}
				}).catch(err => {})
			},
			gotoDetail(item) {
				uni.navigateTo({
					// url: '/pages/journal_dynamics/detail',
					url: '/pages/journal_introduction/detail?id=' + item.id
				})
			}
		}
	};
</script>

<style scoped>
	.nav-right {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.qk-dynamic-box-item-content-bbb {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.qk-dynamic-box-item-content-b {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	.qk-dynamic-box-item-content-t {
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}

	.qk-dynamic-box-item-content {
		width: 430rpx;
		height: 144rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.qk-dynamic-box-item-img {
		width: 192rpx;
		height: 144rpx;
		border-radius: 10rpx;
	}

	.qk-dynamic-box-item:last-of-type {
		border-bottom: none;
	}

	.qk-dynamic-box-item {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		border-bottom: 2rpx solid #E5E5E5;
		margin-bottom: 20rpx;
		padding-bottom: 20rpx;
		/* width: 690rpx; */
	}

	.qk-dynamic-box {
		padding: 20rpx;
	}

	.qk-dynamic {
		width: 710rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
		margin: 0 auto;
		margin-top: 120rpx;
	}

	::v-deep .u-swiper__wrapper {
		width: 690rpx !important;
		height: 286rpx !important;
		border-radius: 6rpx;
	}

	::v-deep .u-swiper__wrapper__item__wrapper__image {
		width: 690rpx !important;
		height: 286rpx !important;
		border-radius: 6rpx;
	}

	::v-deep .u-swiper {
		height: 286rpx !important;
	}


	::v-deep .u-navbar__content {
		width: 750rpx;
		height: 88rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 2rpx 14rpx 0rpx rgba(4, 0, 0, 0.14);
	}

	page {
		background-color: #fff;
	}
</style>